#include <jni.h>

//
// Created by 袁绪龙 on 2024/5/31.
//
#include "triangleegl.h"
#include <android/native_window.h> // requires ndk r5 or newer
#include <android/native_window_jni.h> // requires ndk r5 or newer
#include <android/log.h>

Triangleegl triangleegl = Triangleegl();

extern "C"
JNIEXPORT void JNICALL
Java_com_example_flutter_1test_1opengl_1plugin_TriangleJNILib_initEGL(JNIEnv *env, jclass clazz,
                                                                      jobject surface) {
    ANativeWindow* window = ANativeWindow_fromSurface(env, surface);
    __android_log_print(ANDROID_LOG_ERROR,"ssss","surface 000000=> :%p", window);
    triangleegl.initEGL(window);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_example_flutter_1test_1opengl_1plugin_TriangleJNILib_renderTriangle(JNIEnv *env,
                                                                             jclass clazz) {
    triangleegl.renderTriangle();
}
extern "C"
JNIEXPORT void JNICALL
Java_com_example_flutter_1test_1opengl_1plugin_TriangleJNILib_cleanup(JNIEnv *env, jclass clazz) {
    triangleegl.cleanup();
}